package com.xh.bussiness.tiku.model;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.xh.core.model.SuperEntity;
import com.xh.core.util.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 试题来源
 * </p>
 *
 * @author daiwei
 * @since 2019-02-25
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tiku_question_source")
public class QuestionSource extends Model<QuestionSource> {

    @TableId(value = "id", type = IdType.UUID)
    private String id;

    /**
     * 试题id
     */
    private String questionId;
    /**
     * 年份
     */
    private String year;

    /**
     * 年份名称
     */
    private String yearName;
    /**
     * 省份id
     */
    private String provinceId;
    /**
     * 省份名称
     */
    private String provinceName;
    /**
     * 城市id
     */
    private String cityId;
    /**
     * 城市名称
     */
    private String cityName;
    /**
     * 区域id
     */
    private String areaId;
    /**
     * 区域名称
     */
    private String areaName;
    /**
     * 公立校id
     */
    private String publicSchoolId;
    /**
     * 公立校名称
     */
    private String publicSchoolName;
    /**
     * 字典表来源id
     */
    private String dictSourceId;
    /**
     * 字典表来源名称
     */
    private String dictSourceName;

    private Integer orderNo;

    /**
     * 多个年份
     */
    @TableField(exist = false)
    private List<String> years;

    /**
     * 字典来源id
     */
    @TableField(exist = false)
    private List<String> dictSourceIds;

    @TableField(exist = false)
    public List<String> publicSchoolIds;

    /**
     * 用户查询试题 判断是否传入参数 好进行关联试题来源表 by Pitt Cheung
     * @return
     */
    public boolean hasVal() {
        if (!StringUtils.isEmpty(this.getYear()) || !StringUtils.isEmpty(this.getProvinceId())
                || !StringUtils.isEmpty(this.getCityId()) || !StringUtils.isEmpty(this.getAreaId())
                || !StringUtils.isEmpty(this.getPublicSchoolId()) || !StringUtils.isEmpty(this.getDictSourceId())
                || !CollectionUtils.isEmpty(dictSourceIds) || !CollectionUtils.isEmpty(years)
                || !CollectionUtils.isEmpty(publicSchoolIds)) {
            return true;
        }
        return false;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }
}
